/* jshint esversion:6 */

/**
 * @author: errorcpp@qq.com
 */

var xwindow = ("undefined" != typeof(window)) ? window : global;
xwindow.xlib = xwindow.xlib || {};
let xlib = xwindow.xlib;

/**< 是否开启自动单元测试 */
xlib.__enable_auto_unit_test = true;

/*< 极限值定义 */
xlib.MAX_INT8    =  127;
xlib.MIN_INT8    = -128;
xlib.MAX_INT16   =  32767;
xlib.MIN_INT16   = -32768;
xlib.MAX_INT32   =  2147483647;
xlib.MIN_INT32   = -2147483648;
xlib.MAX_UINT8   =  255;
xlib.MIN_UINT8   =  0;
xlib.MAX_UINT16  =  65535;
xlib.MIN_UINT16  =  0;
xlib.MAX_UINT32  =  4294967295;
xlib.MIN_UINT32  =  0;



/**
 * @brief: 判断val是否是一个有效值（非null 非undefined）
 */
xlib.IsValid = function(val) {
    //let bUndefine = (null == val);
    //let bNull     = ("undefined" == typeof(val));
    //
    //return !(bUndefine || bNull);
    return !((null == val) || ("undefined" == typeof(val)));
};


/**
 * @brief: 断言
 */
xlib.assert = function (exp) {
    if(!exp){
        let e = new Error();
        xlib.warn("assert stack=" + e.stack);
        throw Error("assert !");
    }
};

/**
 * @brief: 带消息的断言
 */
xlib.assert_msg = function (exp, msg) {
    if(!exp){
        let e = new Error();
        xlib.warn("assert stack=" + e.stack);
        throw Error("assert message: " + msg);
    }
};